import os



class XCache(object):
    
    
    def __init__(self, size = -1):
        self.__max_size = size

        self.__map = {}
        self.__current_size = 0
    
    def __len__(self):
        return self.__current_size
    
    def add(self, key, value):
        '''
        添加一个键值
        '''
        
        if self.__max_size > 0 and self.__current_size >= self.__max_size:
            return
        
        self.__map[key] = value
        
        self.__current_size += 1
    
    
    def full(self):
        '''
        是否达到设定的容积
        '''
        return self.__max_size > 0 and self.__current_size >= self.__max_size
            
            
    
    def remove(self, key):
        '''
        删除一个值
        '''    

        if key in self.__map.keys():
            del self.__map[key]
            
    


